﻿using System.Windows;
using MLSharp;
using MLSharp.Clustering;

namespace KnowledgeFrontierMiner
{
	/// <summary>
	/// Interaction logic for SummaryReport.xaml
	/// </summary>
	public partial class SummaryReport : Window
	{
		/// <summary>
		/// Used to build the report once the window has loaded.
		/// </summary>
		private CobwebKnowledgeFrontierDiscovery mKfd;

		/// <summary>
		/// Initializes the report to use the specified run of knowledge frontier discovery.
		/// </summary>
		/// <param name="kfd"></param>
		public SummaryReport(CobwebKnowledgeFrontierDiscovery kfd)
		{
			mKfd = kfd;
			InitializeComponent();
		}

		/// <summary>
		/// Binds the window.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void WindowLoaded(object sender, RoutedEventArgs e)
		{
			//Calculate the min/max/mean size of the frontiers.
			Stats sizeStats = new Stats();

			////Calculate the min/max/mean category utility of the frontiers
			//Stats categoryUtilityStats = new Stats();

			foreach (IKnowledgeFrontier frontier in mKfd.KnowledgeFrontiers)
			{
				sizeStats.Add(frontier.Node.Instances.Count);

	//			categoryUtilityStats.Add(frontier.Node.QualityScore);
			}

			sizeStats.CalculateDerived();
		//	categoryUtilityStats.CalculateDerived();

			MinSize.Text = sizeStats.Min.ToString();
			MaxSize.Text = sizeStats.Max.ToString();
			AverageSize.Text = sizeStats.Mean.ToString();

			//MinCategoryUtility.Text = categoryUtilityStats.Min.ToString();
			//MaxCategoryUtility.Text = categoryUtilityStats.Max.ToString();
			//AverageCategoryUtility.Text = categoryUtilityStats.Mean.ToString();
		}
	}
}
